/**
 * 
 */
package com.antilia.infomaresme.pages.images;

import org.apache.wicket.markup.html.image.NonCachingImage;
import org.apache.wicket.markup.html.image.resource.DynamicImageResource;
import org.apache.wicket.markup.html.panel.Panel;

import com.antilia.infomaresme.data.dao.interfaces.IImageService;
import com.antilia.infomaresme.data.dataobjects.ImageDetail;
import com.google.inject.Inject;

/**
 * @author Ernesto
 *
 */
public class ImagePanel extends Panel {

	private static final long serialVersionUID = 1L;

	@Inject
	private IImageService imagesService;
	
	/**
	 * @param id
	 * @param model
	 */
	public ImagePanel(String id, final ImageDetail detail) {
		super(id);
		add(new NonCachingImage("image", new DynamicImageResource() {
						
				private static final long serialVersionUID = 1L;
	
				@Override
				protected byte[] getImageData() {
					return imagesService.resizeImage(detail, 100, 100).getBytes();
				}
			}));
		}

	public IImageService getImagesService() {
		return imagesService;
	}

	public void setImagesService(IImageService imagesService) {
		this.imagesService = imagesService;
	}



}
